using System;
using System.Collections.Generic;
using System.Text;
using System.Collections ;


namespace BuildingStructuralElements.Sections
{
    /// <summary>
    /// _Section of the BeamElement. from  INSTANT _Section file DataBase
    /// 
    /// </summary>
    /// 
    public class Section:ICloneable
    {
        private string _name;
        private CSectionData _data;
        private CSectionFields _fields;
        public Hashtable _geometry;
        /// <summary>
        /// gets the value of an oldObject 
        /// 
        /// </summary>
        /// <param name="geometric_attribute">name of the oldObject</param>
        /// <returns>oldObject value</returns>
        public  double  getValueOf (string geometric_attribute ) 
        {
            if ((_geometry.Count == 0) && (_fields.Fields.GetLength(0) != 0) && (_data.m_Data.GetLength(0)!= 0))
                fill_geometry();

            if (_geometry.Contains(geometric_attribute))
            {
                 return (double)  _geometry[geometric_attribute];
            }
            return -1;

        }         
        public  void  fill_geometry()
        {

            for (int i = 0; i < 100; i++)
                if (_data.m_Data[i] > 0 && _fields.Fields[i].Name.Length > 0)
                    if (!_geometry.Contains(_fields.Fields[i].Name))
                        _geometry.Add(_fields.Fields[i].Name, _data.m_Data[i]);
        }
        public void Clear()
        {
            _geometry.Clear();

        }
        public string Name
        {
            get { return _name ; }
            set { _name  = value; }
        }
        /// <summary>
        /// This contains the data of the section which are explained 
        /// in fields ;
        /// 
        /// </summary>
        public CSectionData SectionData
        {
            get { return _data; }
            set { this._data = value; }
        }
        /// <summary>
        /// explains data 
        /// </summary>
        public CSectionFields Fields
        {
            get { return _fields; }
            set { this._fields = value; }
        }	
        public Section()
        {
            _data = new CSectionData();
            _fields = new CSectionFields();
            _geometry = new Hashtable();


        }
        public Section(string name )
        {
  
            _data = new CSectionData();
            _fields = new CSectionFields();
            _geometry = new Hashtable();

            this.Name = name;

          
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
